package cn.cscb.mms.server.controller;

import cn.cscb.mms.common.result.Result;
import cn.cscb.mms.pojo.entity.Customer;
import cn.cscb.mms.pojo.entity.TaskInfo;
import cn.cscb.mms.server.service.CustomerService;
import cn.cscb.mms.server.service.TaskInfoService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLOutput;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 我的营销
 * */

@RestController
@RequestMapping("/myMarket")
public class MyMarketController {

    @Resource
    private TaskInfoService taskInfoService;
    @Resource(name = "customerService")
    private CustomerService customerService;

    //客户经理名下的所有营销信息
    @GetMapping("/findAll")
    public Result<IPage<HashMap<String,Object>>> findAll(@RequestParam(value="claim_id",required = true) String claimId,
                                      @RequestParam(value="mark_status",required = false) List<String>  markStatus,
                                      @RequestParam(value="mark_type",required = false) List<String>  markType,
                                      @RequestParam(value="start_date",required = false) Date startDate,
                                      @RequestParam(value="end_date",required = false) Date endDate,
                                      @RequestParam(value="page",required = true) Integer page,
                                      @RequestParam(value="pageSizer",required = true) Integer pageSizer) {
        return Result.success(taskInfoService.findAllMyMarket(claimId,markStatus,markType,startDate,endDate,page,pageSizer));
    }

    //单个客户的详情信息
    @GetMapping("/getCus")
    public Result<Customer> getCusInfoById(@RequestParam("cus_id") Integer cusId) {
        return Result.success(customerService.getCustomerByIdTest01(cusId));
    }

    //单个商机的详情信息
    @GetMapping("/getMarkInfo")
    public Result<TaskInfo> getMarkById(@RequestParam("id") Integer id) {
        return Result.success(taskInfoService.getMarkInfo(id));
    }

    //更新单条商机信息
    @PostMapping("/updateMyMarket")
    public Result<Integer> updateMyMarket(@RequestBody Map<String,Object> map){
        return Result.success(taskInfoService.updateMyMarket(map));
    }

    //退回单条商机
    @PostMapping("/returnMyMarket")
    public Result<Integer> returnMyMarket(@RequestBody Map<String,Object> map){
        return Result.success(taskInfoService.returnMyMarket(map));
    }


}
